<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.rong.hibernate.Const" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>业务单据录入</title>
		<sx:head />
		<script type="text/javascript" src="js/busi.js"></script>
		<style type="text/css">
				@import "css/jquery.datetimeentry.css";
				.isred{color: red; }
		</style>
		<style type="text/css">
@import "css/table.css";
</style>
		<script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" src="js/jquery.datetimeentry.js"></script>
		<script type="text/javascript" src="js/jquery.mousewheel.js"></script>
		<script type="text/javascript" src="js/jquery.datetimeentry-zh-CN.js"></script>
	
		<script type="text/javascript" src="js/busi.js"></script>

		<script type="text/javascript">

		</script>
	</head>
	<body >
		
		<s:form action="BusiAction!edit.action" theme="simple">业务单据|<a href="BusiAction!findallblist.action">业务单据列表</a>

			<table  cellspacing="0">
				<tr>
					<th style="text-align: right">
						系统编号
					</th>
					<td> 
					    <s:textfield name="busi.num" label="单据编号" readonly="true"/>
					</td>
					<th style="text-align: right">
						备注
					</th>
					<td>
						<s:textfield name="busi.remark" label="备注" />
					</td>
					<th style="text-align: right">
						应放热吨位
					</th>
					<td> 
						<s:textfield name="busi.extAttr5" label="应放热吨位" readonly="true"/>
					</td>
					<th style="text-align: right">
						误差吨位
					</th>
					<td>
						<s:textfield name="busi.extAttr6" label="误差吨位"  readonly="true"/>
												
						<s:hidden name="busi.id" />
					    <s:hidden name="busi.waterPriceId" />
					    <s:hidden name="busi.waterPrice" />
					    <s:hidden name="busi.heatPriceId" />
					   
					    <s:hidden name="busi.extAttr2" />
					    
					    <s:hidden name="busi.extattrint1" /> <!-- 采热状态 -->
					    <s:hidden name="busi.extattrint2" /> <!-- 采水状态 -->
					    <s:hidden name="busi.extattrint3" /> <!-- 系统参数id，日报表取油价 -->
					    <s:hidden name="busi.extattrint4" /> <!-- 单据所属分公司,id -->
					    
					     <s:hidden name="busi.extattrdate1" /> <!-- 采热实际付款日期 -->
					      <s:hidden name="busi.extattrdate2" /> <!--采水实际付款日期 -->
					    
					    
					    
					    <s:hidden name="statusid" /> <!-- 状态code -->
					     <s:hidden name="part" /> <!-- 那一部分，采热(part=getheat);采水(part=getwater);运输(part=trsf);供热(part=sell) -->
					      <s:hidden name="returnto" />  <!-- 返回结果页面 -->
					     
					     
					</td>
					<th style="text-align: right">
						 误差吨位调整
					</th>
					<td>
					<s:if test='%{hxright=="0"}'><!-- 用户对供热明细有核销权限时，可以维护误差吨位 -->
						 <s:textfield name="busi.extattrdb3" />
					 </s:if>
					 <s:else>
					 	 <s:textfield name="busi.extattrdb3" readonly="true"/>
					 </s:else>
					 
					  </td>
					<th style="text-align: right">
						 参与奖罚	
					</th>
					<td>
						<s:if test='%{busi.extAttr8=="true"}'>
					
								<s:checkbox label="参与奖罚" name="busi.extAttr8"  value="true"/>
						</s:if>
						<s:else>
								<s:checkbox label="参与奖罚" name="busi.extAttr8" />
						</s:else>				
					</td>
				</tr>				
			</table>
            <p>
			采热方式: <!--<s:radio list="#session.map_steam" name="busi.extAttr1" value="0"/>-->
					<input type="hidden" name="extattr1_code" value="${busi.extAttr1}"> <!-- 标识采热方式状态,决定是否显示水表起至数 -->
			   <s:if test='%{busi.extAttr1=="0"}'>
					废蒸汽<input id=busi.extAttr1 type=radio name=busi.extAttr1 value="0" checked onClick--="dirSteamHs('h')"/> 
				</s:if>
			   <s:else>
			 		  废蒸汽<input id=busi.extAttr1 type=radio name=busi.extAttr1 value="0" onClick--="dirSteamHs('h')"/> 
			   </s:else>
			   <s:if test='%{busi.extAttr1=="1"}'>
					直接蒸汽<input id=busi.extAttr1 type=radio name=busi.extAttr1 value="1" checked onClick--="dirSteamHs('s')"/> 
				</s:if>
				<s:else>
					直接蒸汽<input id=busi.extAttr1 type=radio name=busi.extAttr1 value="1" onClick--="dirSteamHs('s')"/> 
				</s:else>
				 <s:if test='%{busi.extAttr1=="2"}'>
					其他<input id=busi.extAttr1 type=radio name=busi.extAttr1 checked value="2"/>
				</s:if>
				<s:else>
					其他<input id=busi.extAttr1 type=radio name=busi.extAttr1 value="2"/>
				</s:else> 
				
			
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			
			是否采水:<s:checkbox label="是否采水" name="busi.waterIs" onclick="hiddenwater()"/>				
			</p>
			
			
			<table  cellspacing="0" id="part_getheat">
				<tr nowrap>
					<th style="text-align: right">
						采热单号
					</th>
					<td>
						<s:textfield name="busi.heatNum" label="采热单号" />
					</td>
					<th style="text-align: right">
						单&nbsp;据&nbsp;日&nbsp;期&nbsp;
					</th>
					<td>
						<sx:datetimepicker name="busi.heatDate" displayFormat="yyyy-MM-dd" />
					</td>
					
					<td class="td_bg"></td>
					<th style="text-align: right" class="water">
						采水单号
					</th>
					<td class="water">
						<s:textfield name="busi.waterNum" label="采水单号"/>
					</td>

					<th style="text-align: right" class="water">
					单据日期
					</th>
					<td class="water">
						<sx:datetimepicker name="busi.waterDate" displayFormat="yyyy-MM-dd" />
					</td>		
			  </tr>

				<tr nowrap>
					<th style="text-align: right">
						采热地点
					</th>
					<td>
						<s:select label="选择采热地点" list="#session.company_list_suply"
							name="busi.heatComId" listKey="id" listValue="comName"
							headerKey="-1" headerValue="%{#busi.heatComId}" emptyOption="false"/>
					</td>
					<th style="text-align: right" id="dirsteamStartth">
						汽水表起数(选)
					</th>
					<td  id="dirsteamStart"><s:textfield name="busi.extAttr3" label="汽水表开始读数"  onblur="steamSum()"/>	</td>
					<td class="td_bg"></td>
					<th style="text-align: right" class="water">
						采水地点
					</th>
					<td class="water">
						<s:select label="选择采热地点" list="#session.company_list_suply"
							name="busi.waterComId" listKey="id" listValue="comName"
							headerKey="-1" headerValue="%{#busi.waterComId}" emptyOption="false" />
					</td>
						<th style="text-align: right" class="water">						
					</th>
					<td class="water"></td>	
				</tr>

				<tr nowrap>
					
					<th style="text-align: right">
						车辆
					</th>
					<td>
						<s:select label="选择车辆" list="#session.car_list"
							name="busi.heatCarId" listKey="id" listValue="num" headerKey="-1"
							headerValue="%{#busi.heatCarId}" emptyOption="false" />

					</td>  
                       
					<th style="text-align: right"  id="dirsteamEndth">
						汽水表止数(选)
					</th>
					<td  id="dirsteamEnd"><s:textfield name="busi.extAttr4" label="汽水表结束读数" onblur="steamSum()"/></td>
					<td class="td_bg"></td>
					
					<th style="text-align: right" class="water">
						水表开始读数
					</th>
					<td class="water">
						<s:textfield name="busi.waterMeterStar" label="水表开始读数"  onblur="waterSum_1()"/>
					</td>
					
					<th style="text-align: right" class="water">
						水表结束读数
					</th>
					<td class="water">
						<s:textfield name="busi.waterMeterEnd" label="水表结束读数"  onblur="waterSum_1()"/>
					</td>
					
                 </tr>
                 <tr nowrap>
                    <th style="text-align: right">
						采热成本
					</th>
					<td>
						<s:hidden name="busi.heatPrice" label="采热单价" /> <!-- 废蒸汽方式，采热单价极为采热成本；直接蒸汽方式采热成本=单价×水表走数 -->
						<s:textfield name="busi.heatSum" label="采热成本金额" />
					</td>
					<th style="text-align: right">
						
					</th>
					<td> </td>
					<td class="td_bg"></td>
					
					<th style="text-align: right" class="water">
						
					</th>
					<td class="water">
						<!--<s:select label="选择车辆" list="#session.car_list"
							name="busi.waterCarId" listKey="id" listValue="num" headerKey="-1"
							headerValue="%{#busi.waterCarId}" emptyOption="false" />
							-->
						<s:hidden name="busi.waterCarId" />
					</td>
					
					<th style="text-align: right" class="water">
						采水成本
					</th>
					<td class="water">
						<s:textfield name="busi.waterSum" label="采水成本金额" onblur="waterSum_1()"/>
					</td>
			
                  </tr>
                 
			</table>


			<!--客户销售部分 -->
    <p>    客户销售结算 </p>
          <table id="sellTable" class="pill" cellspacing="0">
				<tr>
					
					<th>
						供热类型
					</th>
					<th>
						客户
					</th>
					
					<th>
						原始单号
						<font color="red">(*)</font>
					</th>
					<th>
						结算方式
					</th>
					<th>
						结算单价
					</th>
					<th>
						水表起
					</th>
					<th>
						水表止
					</th>
					<th>
						结算数量
					</th>
					
					<th>
						金额
					</th>
					
					
					<th>
						原水温
					</th>
					<th>
						放热温度
					</th>
					<th>
						备注
					</th>
					<th>
						已收金额
					</th>
					<th>
					</th>
				</tr>
				
				<s:iterator id="slist" value="sellList" status="sellt">
							<tr>					
									
								<td>
								
								<s:hidden name="sellList[%{#sellt.index}].extattr2" value="%{#slist.extattr2}"></s:hidden>
								<s:hidden name="sellList[%{#sellt.index}].extattr3" value="%{#slist.extattr3}"></s:hidden>
								<s:hidden name="sellList[%{#sellt.index}].extattr4" value="%{#slist.extattr4}"></s:hidden><!-- 单据所属分公司,id -->
								
								<s:hidden name="sellList[%{#sellt.index}].offerHeatTime" value="%{#slist.offerHeatTime}"></s:hidden> <!-- 供热日期 -->
								<s:hidden name="sellList[%{#sellt.index}].extattrdate1" value="%{#slist.extattrdate1}"></s:hidden> <!-- 实际收款日期 -->
								
									<s:select label="供热类型" list="#session.map_heat_style"
										name="sellList[%{#sellt.index}].extattr1" listKey="key" listValue="value" emptyOption="false" headerValue="%{#slist.extattr1}" />
								</td>
								<td>
								    <s:hidden name="sellList[%{#sellt.index}].comFromId" value="%{#slist.comFromId}"  />
									<s:select label="客户" list="#session.company_list_custom"
										name="sellList[%{#sellt.index}].comToId" listKey="id" listValue="comName"
										headerKey="-1" headerValue="%{#slist.comToId}" emptyOption="false" />
								</td>
								
								<td>
								<s:hidden name="sellList[%{#sellt.index}].carId" value="%{#slist.carId}" />
									<s:textfield name="sellList[%{#sellt.index}].sellNum" value="%{#slist.sellNum}" />
								</td>
								<td>
									<s:select label="结算方式" list="#session.statmap"
										name="sellList[%{#sellt.index}].stmtStyle" listKey="key" listValue="value"
										headerKey="-1" headerValue="%{#slist.stmtStyle}" emptyOption="false" />
									<!--<s:textfield name="sellList[%{#sellt.index}].stmtStyle"/>-->
								</td>
								<td>
									<s:hidden name="sellList[%{#sellt.index}].priceId" value="%{#slist.priceId}"/>
									<s:textfield name="sellList[%{#sellt.index}].price" value="%{#slist.price}"/>
								</td>
								<td>
									<s:textfield name="sellList[%{#sellt.index}].meterStart"  value="%{#slist.meterStart}"/>
								</td>
								<td>
									<s:textfield name="sellList[%{#sellt.index}].meterEnd"  value="%{#slist.meterEnd}"/>
								</td>	
								<td>
									<s:textfield name="sellList[%{#sellt.index}].amount"  value="%{#slist.amount}" />
								</td>
								
								<td>
								<s:hidden name="sellList[%{#sellt.index}].sumPlus"  value="%{#slist.sumPlus}"/>
									<s:textfield name="sellList[%{#sellt.index}].sum" readonly="true" value="%{#slist.sum}"/>
								</td>
												
								<td>
								<s:hidden name="sellList[%{#sellt.index}].offerHeatTime"  value="%{#slist.offerHeatTime}"/>
									<s:textfield name="sellList[%{#sellt.index}].cstmTemptStart"  value="%{#slist.cstmTemptStart}"/>
								</td>
								<td>
									<s:textfield name="sellList[%{#sellt.index}].cstmTemptEnd"  value="%{#slist.cstmTemptEnd}"/>
									<s:hidden  name="sellList[%{#sellt.index}].carv" value="%{#slist.carv}"/> <!-- 车辆容积 -->
									<s:hidden    name="sellList[%{#sellt.index}].upTemprature" value="%{#slist.upTemprature}"/><!-- 充热温度 -->
									<s:hidden   name="sellList[%{#sellt.index}].sHeatAmount" value="%{#slist.sHeatAmount}"/><!-- 应放热吨位 -->
									<s:hidden   name="sellList[%{#sellt.index}].fangreAmount" value="%{#slist.fangreAmount}"/><!-- 车辆水箱的标准放热量 -->
								</td>
								<td>
									<s:textfield name="sellList[%{#sellt.index}].remark" />
								</td>
								<td>						
									<s:if test='%{hxright=="0"}'>
										<s:textfield name="sellList[%{#sellt.index}].extattrDoub5"	/> <!--有核销权限则 可以填写该项，  已收金额（包括正常已收金额，和呆账的已收金额，按核销状态区分是否呆账）,录入状态下默认为0 -->
									</s:if>
									<s:else>
										<s:textfield name="sellList[%{#sellt.index}].extattrDoub5"	readonly="true"/> <!--没有权限不可以维护该选项， 已收金额（包括正常已收金额，和呆账的已收金额，按核销状态区分是否呆账）,录入状态下默认为0 -->
									</s:else>
									
								</td>
								<td>
								
								<s:if test='%{#slist.extattr3==10}'>
									<a href="#" onclick="deleRecEdit(this)" name="sellList[%{#sellt.index}].deleRec" >删除 </a>
								</s:if>	
									
									<s:hidden name="sellList[%{#sellt.index}].id" value="%{#slist.id}"></s:hidden>
								</td>
							</tr>
				</s:iterator>
			</table>
			<p id="sellTaltolSum">金额合计：<s:textfield name="busi.sellTaltolSum" label="销售金额合计" readonly="true" /></p>
			<p>
				<input type="button" value="增加记录" onclick="addsell()" />
				<s:textfield  id="totalAmount" name="busi.totalAmount" /> <!--总的结算数量 -->
			</p>


			<!-- 运费部分 -->
		
				<p> 是否承包方结算:	<s:checkbox label="是否承包方结算" name="busi.extAttr7" onclick="hiddentransf()"/>	</p>
		

           <table id="transTable" class="pill" cellspacing="0">
				<tr>
					<th>
						热源地
					</th>
					<th>
						客户
					</th>
					
					<th nowrap>
						原始单号
						<font color="red">(*)</font>
					</th>
					<th>
						结算方式
					</th>
					<th>
						单价
					</th>
					<th>
						数量
					</th>
					
					<th>
						金额
					</th>
					<th>
						里程表起
					</th>
					<th>
						里程表止
					</th>
					<th>
						备注
					</th>
					
					<th>
					</th>
				</tr>

			<s:iterator id="tlist" value="transfList" status="st">

							<tr>
								<td>
								
								<s:hidden name="transfList[%{#st.index}].extattr2" value="%{#tlist.extattr2}"></s:hidden>
								<s:hidden name="transfList[%{#st.index}].extattr3" value="%{#tlist.extattr3}"></s:hidden>
								<s:hidden name="transfList[%{#st.index}].extattr4" value="%{#tlist.extattr4}"></s:hidden> <!-- 单据所属分公司,id -->
								<s:hidden name="transfList[%{#st.index}].extattrdate1" value="%{#tlist.extattrdate1}"></s:hidden> <!-- 实际付款日期 -->
								<s:hidden name="transfList[%{#st.index}].extattrdate2" value="%{#tlist.extattrdate2}"></s:hidden> <!-- 单据日期 -->
									<s:select label="采热地点" list="#session.company_list_suply"
										name="transfList[%{#st.index}].comFromId" listKey="id" listValue="comName"
										headerKey="-1" headerValue="%{#tlist.comFromId}" emptyOption="false" > </s:select>									
								</td>
								<td>
									<s:select label="客户" list="#session.company_list_custom"
										name='transfList[%{#st.index}].comToId' listKey="id" listValue="comName"
										headerKey="-1" headerValue="%{#tlist.comToId}" emptyOption="false" />
								</td>
								
								<td>
								<s:hidden name="transfList[%{#st.index}].carId" value="%{#tlist.carId}" />
									<s:textfield name="transfList[%{#st.index}].tranNum" value="%{#tlist.tranNum}" />
								</td>
								<td>
									<s:select label="结算方式" list="#session.statmap"
										name="transfList[%{#st.index}].stmtStyle" listKey="key" listValue="value"
										headerKey="-1" headerValue="%{#tlist.stmtStyle}" emptyOption="false" />
									<!--<s:textfield name="transfList[%{#st.index}].stmtStyle"/>-->
								</td>
								<td>
									<s:hidden name="transfList[%{#st.index}].priceId" value="%{#tlist.priceId}"/>
									<s:textfield name="transfList[%{#st.index}].price" value="%{#tlist.price}"/>
								</td>
								<td>
									<s:textfield name="transfList[%{#st.index}].amount" value="%{#tlist.amount}"/>
								</td>
			
								<td>
								    <s:hidden name="transfList[%{#st.index}].sumPlus" value="%{#tlist.sumPlus}"/>
									<s:textfield name="transfList[%{#st.index}].sum"  readonly="true" value="%{#tlist.sum}"/>
								</td>
								<td>
									<s:textfield name="transfList[%{#st.index}].meterStart" value="%{#tlist.meterStart}"/>
								</td>
								<td>
									<s:textfield name="transfList[%{#st.index}].meterEnd" value="%{#tlist.meterEnd}"/>
								</td>
								<td>
									<s:textfield name="transfList[%{#st.index}].remark" value="%{#tlist.remark}"/>
								</td>
								
								<td>
								<s:if test='%{#tlist.extattr3==10}'>
									<a href="#" onclick="deleRecEdit(this)" name="transfList[%{#st.index}].deleRec" >删除 </a>
								</s:if>
								<s:hidden name="transfList[%{#st.index}].id" value="%{#tlist.id}"></s:hidden>
								</td>
							</tr>
				</s:iterator>
				
			</table>
			<p id="transfTaltolSum">金额合计：<s:textfield name="busi.transfTaltolSum" label="运输金额合计" readonly="true" /></p>
			<p id="transfTaltolbutton">
				<input type="button" value="增加记录" onclick="add()" />
			</p>

			<table  cellspacing="0">
				<tr>
					<td style="text-align: right">
						<s:submit value="保存" />
					</td>
					<td style="text-align: left">
						<s:reset value="取消" />
					</td>

					<td style="text-align: left">
						${saveFlag}
					</td>

				</tr>
			</table>
		</s:form>
		<s:fielderror cssStyle="color:red" />
	</body>
</html>
